package com.sdhs.paas.itims.service;

import java.util.List;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.sdhs.paas.sdk.base.common.BaseDao;
import com.sdhs.paas.sdk.base.common.BasePage;
import com.sdhs.paas.sdk.base.page.Page;
import com.sdhs.paas.sdk.core.PaasBaseException;
import com.sdhs.paas.sdk.core.mybatis.EnablePaasMybatis;
import com.sdhs.paas.itims.bean.VersionPublishDetailBean;
import com.sdhs.paas.itims.repository.VersionPublishDetailMapper;

/**
* 描述：VersionPublishDetailService 服务接口
* @author kangjichang
* @date 2018-09-25
*/

@EnablePaasMybatis
@MapperScan("com.sdhs.paas.itims.repository")
@Service
public class VersionPublishDetailService extends BaseDao<VersionPublishDetailBean, VersionPublishDetailMapper, Integer>{
		@Override
		public String getMapperNamespace() {
			return VersionPublishDetailMapper.class.getName();
		}
		
		@Autowired
		private VersionPublishDetailMapper versionPublishDetailMapper;
		
		@SuppressWarnings("deprecation")
		public Page<VersionPublishDetailBean> getPageVersionPublishDetailList(BasePage pageRequest, VersionPublishDetailBean versionPublishDetailBean) {
			pageRequest.setFilters(versionPublishDetailBean);
			Page<VersionPublishDetailBean> page = pageQuery(pageRequest);
			return page;
		}
		
		@Transactional(rollbackFor = Exception.class)
		public boolean saveVersionPublishDetail(VersionPublishDetailBean versionPublishDetailBean) {
			try {
				//ucAppBean.setCtime(System.currentTimeMillis());
				//ucAppBean.setUtime(System.currentTimeMillis());
				int count = versionPublishDetailMapper.insertVersionPublishDetail(versionPublishDetailBean);
				return count == 1;
			} catch (Exception e) {
				throw new PaasBaseException(e, "500", "数据库插入异常！");
			}
		}
		
		@Transactional(rollbackFor = Exception.class)
		public boolean saveVersionPublishDetailList(List<VersionPublishDetailBean> versionPublishDetailBeanList) {
			try {
				int count = versionPublishDetailMapper.insertVersionPublishDetailList(versionPublishDetailBeanList);
				return count >= 1;
			} catch (Exception e) {
				throw new PaasBaseException(e, "500", "数据库插入异常！");
			}
		}
	
		@Transactional(rollbackFor = Exception.class)
		public boolean updateVersionPublishDetail(VersionPublishDetailBean versionPublishDetailBean) {
			try {
				//ucAppBean.setUtime(System.currentTimeMillis());
				int count = versionPublishDetailMapper.updateVersionPublishDetail(versionPublishDetailBean);
				return count == 1;
			} catch (Exception e) {
				throw new PaasBaseException(e, "500", "数据库插入异常！");
			}
		}
	
		public VersionPublishDetailBean getVersionPublishDetailDetail(String id) {
			return versionPublishDetailMapper.getVersionPublishDetailDetail(id);
		}
		
		public boolean deleteVersionPublishDetail(VersionPublishDetailBean versionPublishDetailBean){
			return versionPublishDetailMapper.deleteVersionPublishDetail(versionPublishDetailBean)>0;
		}
		
		@Transactional(rollbackFor = Exception.class)
		public boolean updatePosReportStataus(VersionPublishDetailBean versionPublishDetailBean) {
			try {
				//ucAppBean.setUtime(System.currentTimeMillis());
				int count = versionPublishDetailMapper.updatePosReportStataus(versionPublishDetailBean);
				return count >= 1;
			} catch (Exception e) {
				throw new PaasBaseException(e, "500", "数据库插入异常！");
			}
		}
		
      
}